clear; clc; close all;
% 绘制 MNFM1～MNFM6 的混沌吸引子 (x, y)
% 使用外部函数 f1.m ~ f6.m

% ============ 1. 参数与设置 ============
a = 0.02;
b = 2.6;
c = 1.1;
d = 0.001;

N = 50000;      % 迭代总数，可根据需求加大
discard = 5000; % 丢弃暂态步数

x0 = 1.0;       % 初始条件
y0 = 2.0;

% ============ 2. 函数句柄与标题 ============
% 注意这里的 @f1, @f2... 即外部文件中定义的函数名
funcs = {@f1, @f2, @f3, @f4, @f5, @f6};
titles = {'MNFM1','MNFM2','MNFM3','MNFM4','MNFM5','MNFM6'};

% ============ 3. 创建图形并迭代绘图 ============
figure('Color','w');

for i = 1:length(funcs)
    % 为每个映射分别分配空间
    x = zeros(N,1);
    y = zeros(N,1);
    x(1) = x0;
    y(1) = y0;
    
    for k = 1 : N-1
    [x(k+1), y(k+1)] = funcs{i}(x(k), y(k), a, b, c, d);
    end
    % 丢弃初始暂态
    xplot = x(discard+1:end);
    yplot = y(discard+1:end);
    
    % 在子图中绘制 (x, y)
    subplot(3, 2, i)
    plot(xplot, yplot, '.', 'MarkerSize', 1, 'Color','k');
    title(titles{i}, 'Interpreter','latex','FontSize',14)
    xlabel('$x$','Interpreter','latex','FontSize',12);
    ylabel('$y$','Interpreter','latex','FontSize',12);
    
    set(gca, 'FontName','Times New Roman', 'FontSize',12);
    axis tight;
    box on;
end

% exportgraphics(gcf, 'mnfm_maps.png', 'Resolution',300);
